package com.jl.driver.vritual.ternimal;

import javax.comm.*;
import java.util.*;

public class COMException extends Exception
{
	public COMException(String msg)
	{
		super(msg);
	}
	
	public static void throwIt(String s) throws COMException
	{
		throw new COMException(s);
	}
	
	public static void throwIt(Exception e) throws COMException
	{
		String s = null;
		if (e instanceof PortInUseException) 
		{
			s = "Port is in used.";
		}
		else if (e instanceof TooManyListenersException) 
		{
			s = "Too many listeners.";
		}
		else if (e instanceof NoSuchPortException) 
		{
			s = "No such port.";
		}
		else if (e instanceof UnsupportedCommOperationException) 
		{
			s = "Unsupported comm operation.";
		}
		else
		{
			s = "Exception: " + e.getMessage();
		}
		
		e.printStackTrace();
		throwIt(s);
	}
	
}
